from rest_framework import serializers

from recruitments.models import City, Enterprise, Recruit


class CitySerializer(serializers.ModelSerializer):

    class Meta:
        model = City
        fields = '__all__'

class EnterpriseVisitSerializer(serializers.ModelSerializer):


    class Meta:
        model = Enterprise
        fields = '__all__'



class EnterpriseSerializer(serializers.ModelSerializer):
    recruits = serializers.PrimaryKeyRelatedField(read_only=True,many=True)
    class Meta:
        model = Enterprise
        fields = ('id','name','labels','logo','recruits','summary')



class RecuitsVisitSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer()
    class Meta:
        model = Recruit
        fields = ("id",
                  "jobname",
                  "salary",
                  "condition",
                  "education",
                  "type",
                  "city",
                  "createtime",
                  "enterprise",
                  "labels")
class EnterpriseHotlistSerializer(serializers.ModelSerializer):
    recruits = serializers.PrimaryKeyRelatedField(read_only=True, many=True)
    class Meta:
        model = Enterprise
        fields = ('id',
                  'name',
                  'labels',
                  'logo',
                  'recruits',
                  'summary'
                  )



class RecruitsIDallSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer()
    class Meta:
        model = Recruit
        fields = '__all__'


class EnterpriseIDSerializer(serializers.ModelSerializer):
    recruits = RecruitsIDallSerializer(many=True)
    class Meta:
        model = Enterprise
        fields = '__all__'

class RecruitsIdSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseIDSerializer()
    class Meta:
        model = Recruit
        fields = '__all__'